// 1. 引入第三方包的一些方法, 帮助我们创建路由
import { createRouter, createWebHashHistory } from "vue-router";

// import homeCom1 from "../views/home.vue";
// import homeCom2 from "../views/cart.vue";
// import homeCom3 from "../views/login.vue";
// import homeCom4 from "../views/banner/index.vue";

const routes = [
    {
        // 路由地址
        path: "/",
        name: "/",
        // 对应路由显示组件
        // component: homeCom1,
        component: () => import("../views/home.vue"),
    },
    {
        path: "/cart",
        name: "cart",
        // component: homeCom2,
        component: () => import("@/views/cart.vue"),
    },
    {
        path: "/login",
        name: "login",
        component: () => import("../views/login.vue"),
    },
    {
        path: "/banner",
        name: "banner",
        component: () => import("../views/banner/index.vue"),
        children: [
            {
                path: "bannerlist",
                name: "bannerlist",
                component: () =>
                    import("../views/banner/components/bannerList.vue"),
            },
            {
                path: "addbanner",
                name: "addbanner",
                component: () =>
                    import("../views/banner/components/addBanner.vue"),
            },
        ],
    },
];

// 2. 创建一个路由实例
const router = createRouter({
    // 确定路由模式,当前使用hash模式
    history: createWebHashHistory(),
    // 定义路由表
    routes,
});

// 3. 导出当前路由实例
export default router;
